<?php

/**
 * xmlIO:
 *
 * @author: Andreas
 */
class xmlIO {
	private $filename = "";
        
	/**
	 * Create new xmlIO
	 * 
	 * @param unknown_type $file
	 */
    public function __construct($file) {
        $this->filename = $file;
    }
	
	/**
	 * Loads the xml file $filename
	 */
	public function loadXML() {
		if(file_exists($this->filename)){
			$this->xml = simplexml_load_file($this->filename);
		} else {
			exit('Failed to load xml file, the file do not exist');
		}
        
		return $this->xml;
	}
	
	/**
	 * Saving the XML file, the file must have FULL-rights (CHMOD 777)
	 * @param unknown_type $xml
	 */
	public function saveXML($xml){
		$xml->asXML($this->filename);
	}
}
?>